<?php

namespace App\Http\Controllers;

use EasyWeChat\Foundation\Application;

class CallbackController extends Controller
{
    public function common()
    {
        $app   = new Application(config('wechat'));
        $oauth = $app->oauth;

        // 获取 OAuth 授权结果用户信息
        $user                    = $oauth->user();
        $_SESSION['wechat_user'] = $user->toArray();
        $targetUrl               = empty($_SESSION['target_url']) ? '/' : $_SESSION['target_url'];
        var_dump($targetUrl);
        header('location:' . $targetUrl);
    }
}
